﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using InfoStuffStore.Common;

namespace InfoStuffStore
{
    public partial class FormContactUs : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            using (DBDataContext dataContext = new DBDataContext())
            {
                ContactMessage message = new ContactMessage()
                {
                    CreatedDate = DateTime.Now,
                    EmailID = txtEmail.Text,
                    Message = txtMessage.Text,
                    Name = txtName.Text,
                    Subject = txtSubject.Text
                };

                dataContext.ContactMessages.InsertOnSubmit(message);
                dataContext.SubmitChanges();

                txtEmail.Text = string.Empty;
                txtMessage.Text = string.Empty;
                txtName.Text = string.Empty;
                txtSubject.Text = string.Empty;

                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Message sent successfully! We will reply back soon.')", true);
            }
        }
    }
}